package ch.phovoz.tlog.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseManager extends SQLiteOpenHelper {
	
	   public final static String DB_NAME="traindb.db";
	   public final static int DB_VERSION = 1;
	   public final static String MY_DB_NAME="TrainDB";
	   public final static String TABLE_Training="training";
	   public final static String TABLE_EXERSICE="exersice";
	   public final static String TABLE_REPSET="repset";
	   public final static String TABLE_EXERSICENAME="exersicenname";
	   
	   final static String TRAINING_CREATE=
			   "CREATE TABLE IF NOT EXISTS " + TABLE_Training 
			   
			   + "( _id integer PRIMARY KEY AUTOINCREMENT," 
			   + "startdate varchar(100),"
			   + "enddate varchar(100),"
			   + "total integer(8))"	 
			   +";";
	   
	   final static String EXERSICE_CREATE=
			   "CREATE TABLE IF NOT EXISTS " + TABLE_EXERSICE
			   + "( _eid integer PRIMARY KEY AUTOINCREMENT,"
			   +"trainingsid integer(10),"
			   +"starttime varchar(100),"
			   +"endtime varchar(100),"
			   +"totalw integer(8),"
			   +"exersiceNameid integer(8))"
			   +";"; 
	   
	   final static String REPSET_CREATE=
			   "CREATE TABLE IF NOT EXISTS " + TABLE_REPSET
			   +"(repid integer PRIMARY KEY AUTOINCREMENT,"
			   +"exID integer(10),"
			   +"weight integer(5),"
			   +"reps integer(5))"
			   +";";
	   
	   final static String EXERSICENAME_CREATE=
			   "CREATE TABLE IF NOT EXISTS " + TABLE_EXERSICENAME
			   +"(_id integer PRIMARY KEY AUTOINCREMENT,"
			   +"name varchar(100))"
			   +";";
			 
	
	public DatabaseManager(Context context){
		super(context, DB_NAME, null, DB_VERSION);
		
	}
	 

	public void onCreate(SQLiteDatabase db) {
		db.execSQL(TRAINING_CREATE);
		db.execSQL(EXERSICE_CREATE);
		db.execSQL(REPSET_CREATE);
		db.execSQL(EXERSICENAME_CREATE);
		
	}
	
	

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
	
		
	}

}
